package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportTaskReply;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2020-05-20 17:34:41
 */
@Repository
public class TransportTaskReplyDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportTaskReplyDao.class);

    public TransportTaskReply insert(final TransportTaskReply transportTaskReply) {
        insert("TransportTaskReply.insert", transportTaskReply);
        return transportTaskReply;
    }

    public Boolean updateInfoById(final TransportTaskReply transportTaskReply) {
        return update("TransportTaskReply.updateInfoById", transportTaskReply) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportTaskReply.updateInfoByQuery", query) > 0;
    }

    public TransportTaskReply selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("TransportTaskReply.selectById", query);
    }

    public List<TransportTaskReply> selectByQuery(final Query query) {
        return queryForList("TransportTaskReply.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportTaskReply.countByQuery", query);
    }

    public Boolean deleteById(final Integer id) {
        TransportTaskReply transportTaskReply = new TransportTaskReply();
        transportTaskReply.setDeleteFlag(1);
        transportTaskReply.setId(id);

        return update("TransportTaskReply.updateInfoById", transportTaskReply) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportTaskReply.deleteById", query) > 0;
    }
}